﻿using MediatR;
using S.Eartag.Domain.Model;
using S.Eartag.Infrastructure.Interface;
using S.Eartag.Read.API.Application.Command.LamBingCommand;

namespace S.Eartag.Read.API.Application.CommandHandlers.LamBingCommandHandler
{
    public class LamBingGetsCommandHandler : IRequestHandler<LamBingGetsCommand, List<LamBing>>
    {
        private readonly ILamBingRepository lamBingRepository;

        public LamBingGetsCommandHandler(ILamBingRepository lamBingRepository)
        {
            this.lamBingRepository = lamBingRepository;
        }

        public async Task<List<LamBing>> Handle(LamBingGetsCommand request, CancellationToken cancellationToken)
        {
            var res = await lamBingRepository.GetValues(x => x.EarNumber == request.card);
            return res.ToList();
        }
    }
}
